﻿#include "Model/Bough.h"
#include "cocos2d.h"
#include "cocos-ext.h"
#include "Config.h"
#include "Component/MonkeyCollision.h"

using namespace cocos2d;
using namespace cocos2d::extension;

Bough::Bough()
{

	initValueForAttribute( FBANANA, ccp(0,0), FISLEFT); 

}
Bough::Bough(int type)
{
	initValueForAttribute( type, ccp(0,0), FISLEFT);
}
Bough::Bough(int type, CCPoint p)
{

	initValueForAttribute( type, p, FISLEFT);
}
Bough::Bough(int type, CCPoint p, int left)
{
	initValueForAttribute( type, p, left);
}

void Bough::initValueForAttribute(int type, CCPoint p, int left)
{
	initWithFile(fSelectObjectImage());
	mType = type;
	if(left == 1)
	{
		p.x -= getContentSize().width/2;
	}
	else
	{
		p.x += getContentSize().width/2;
	}
	setPosition(p);
	mIsLeft = left;
	mNewStatus = BSHOW;
	mCurrentStatus = BSHOW;

}

char* Bough::fSelectObjectImage()
{
	switch(mType)
	{
	case BTYPE1:
		return kImageBoughType1;
	case BTYPE2:
		return kImageBoughType2;
	default: 
		return kImageBoughType1;
	}
}

void Bough::fPreLoadMusic()
{
	CCLog("PreLoad music !!!!");
	//CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(kSoundBroken);
}


void Bough::fEffect()
{
	switch(mCurrentStatus)
	{
			//action
			//play sound effect here

		case BSHOW: //hien
			// CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(kSoundBroken);
			break;

		case BBREAK: //an
			// CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(kSoundBroken);
			break;

		case BCOLLISION: //va cham
			// CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(kSoundBroken);
			break;

		default: 
			break;
	}
}
